package cloud.maque.admin.controller;

import cloud.maque.admin.annotations.MaquerManager;
import cloud.maque.admin.domain.entity.MqCombo;
import cloud.maque.admin.service.MqComboService;
import cloud.maque.framework.common.request.PaginateDataResquest;
import cloud.maque.framework.common.response.ResponseBodyVo;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author zhuyf
 * @date 2023/5/13 18:01
 */
@RestController
@RequestMapping(value = "/combo")
@Api(tags = "运维-租户套餐")
public class ComboController {


    @Resource
    private MqComboService mqComboService;

    /**
     * 保存
     *
     * @date 2023/05/13
     **/
    @PostMapping("/save")
    @ApiOperation(value = "新增或修改")
    @MaquerManager
    public ResponseBodyVo<MqCombo> insert(@RequestBody MqCombo mqComboMenu) {
        return ResponseBodyVo.Success(mqComboService.saveCombo(mqComboMenu));
    }

    /**
     * 刪除
     *
     * @date 2023/05/13
     **/
    @DeleteMapping("/delete/{id}")
    @ApiOperation(value = "刪除")
    @MaquerManager
    public ResponseBodyVo<Boolean> delete(@PathVariable("id") String id) {
        return ResponseBodyVo.Success(mqComboService.deleteById(id));
    }


    /**
     * 查询 根据主键 id 查询
     *
     * @date 2023/05/13
     **/
    @GetMapping("/load/{id}")
    @ApiOperation(value = "查询单个")
    public ResponseBodyVo<MqCombo> load(@PathVariable("id") String id) {
        return ResponseBodyVo.Success(mqComboService.getById(id));
    }

    /**
     * 查询 查询
     *
     * @date 2023/05/13
     **/
    @PostMapping("/page")
    @ApiOperation(value = "查询")
    public ResponseBodyVo<PageInfo<MqCombo>> page(@RequestBody @ApiParam("查询内容") PaginateDataResquest<MqCombo> pageReq) {
        return ResponseBodyVo.Success(mqComboService.page(pageReq));
    }
}
